export default function field({ t }) {
  return [
    {
      type: 'FieldInput',
      field: 'field',
      value: '',
      title: t('form.field')
    },
    {
      type: 'input',
      field: 'title',
      value: '',
      title: t('form.title')
    },
    {
      type: 'input',
      field: 'info',
      value: '',
      title: t('form.info')
    },
    {
      type: 'input',
      field: '$help',
      value: '',
      title: '帮助信息',
      effect: {
        help: '当前帮助信息显示到输入框下面，具体效果查看预览'
      }
    },
    {
      type: 'SizeInput',
      field: 'formCreateWrap>labelWidth',
      value: '',
      title: t('form.labelWidth')
    },
    {
      type: 'radio',
      field: 'controlType',
      value: 'input',
      title: '联动数据方法',
      options: [
        { label: '手动输入', value: 'input' },
        { label: '快捷配置', value: 'select' }
      ],
      control: [
        {
          value: 'input',
          rule: [
            {
              type: 'Struct',
              field: '_control',
              value: [],
              title: t('form.control'),
              info: {
                type: 'tooltip',
                native: true,
                effect: 'dark',
                placement: 'top-end',
                align: 'left',
                content: t('form.controlDocument', {
                  doc:
                    '<a target="_blank" href="https://form-create.com/v3/guide/control" style="color: inherit;text-decoration: underline;">' +
                    t('form.document') +
                    '</a>'
                }),
                rawContent: true
              },
              props: {
                defaultValue: [],
                validate(val) {
                  if (!Array.isArray(val)) return false
                  if (!val.length) return true
                  return !val.some(({ rule }) => {
                    return !Array.isArray(rule)
                  })
                }
              }
            }
          ]
        },
        {
          value: 'select',
          rule: [
            {
              type: 'DkGroup',
              title: '配置',
              field: '_controls',
              value: [],
              props: {
                defaultValue: [],
                rule: [
                  {
                    type: 'radio',
                    title: '判断值',
                    field: 'valueType',
                    value: 'eq',
                    options: [
                      { label: '等于固定值', value: 'eq' },
                      { label: '手动输入', value: 'input' }
                    ],
                    control: [
                      {
                        value: 'input',
                        rule: [
                          {
                            type: 'input',
                            props: { type: 'textarea' },
                            title: '自定义判断条件',
                            field: 'custom_value',
                            value: '',

                            info: {
                              native: true,
                              width: '300px',
                              children: [
                                {
                                  type: 'span',
                                  props: {
                                    innerHTML:
                                      "手动输入输入全，比如:<br/>value:'123' <br/>或者 <br>handle:(val, fApi)=>{return val === 1} <br> 如果过于复杂的判断逻辑，推荐自己参考文档写完整版本"
                                  }
                                }
                              ]
                            }
                          }
                        ]
                      },
                      {
                        value: 'eq',
                        rule: [
                          {
                            type: 'radio',
                            title: '值类型',
                            field: 'valueType',
                            value: 'string',
                            options: [
                              { label: '字符串', value: 'string' },
                              { label: '数字', value: 'number' },
                              { label: '布尔', value: 'boolean' }
                            ],
                            control: [
                              {
                                value: 'string',
                                rule: [{ type: 'input', title: '固定值', field: 'value', value: '' }]
                              },
                              {
                                value: 'number',
                                rule: [{ type: 'inputNumber', title: '固定值', field: 'value', value: 0 }]
                              },
                              {
                                value: 'boolean',
                                rule: [
                                  {
                                    type: 'switch',
                                    title: '固定值',
                                    field: 'value',
                                    value: false,
                                    props: { activeText: 'True', inactiveText: 'False' }
                                  }
                                ]
                              }
                            ]
                          }
                        ]
                      }
                    ]
                  },
                  {
                    type: 'FcDesignerInput',
                    field: 'rules',
                    title: '表单规则',
                    value: {},
                    style: {
                      width: 'calc(100% - 15px)'
                    }
                  }
                ]
              }
            }
          ]
        }
      ]
    }
  ]
}
